# 7-1 排序输出字典中数据【组合数据类型】
dic1 = {'Tom':21,'Bob':18,'Jack':23,'Ana':20}
dic2 = {'李雷':21,'韩梅梅':18,'小明':23,'小红':20}
s=int(input())
# s=2
dic12=sorted(dic1.items(),key=lambda x:x[0],reverse=False)
dic22=sorted(dic2.items(),key=lambda x:x[1],reverse=False)
dic1Final=[]
dic2Final=[]
if s>len(dic12):
    s=len(dic12)
for i in range(s):
    dic1Final.append(dic12[i][0])
    dic2Final.append(dic22[i])
print(dic1Final)
print(dic2Final,end="")